from PyPDF2 import PdfFileReader, PdfFileWriter

filename = "../demo.pdf"
with open(filename, "rb") as handler:
    pdf = PdfFileReader(handler)
    info = pdf.getDocumentInfo()
    pages = pdf.getNumPages()
    # {'/Producer': 'Acrobat Distiller 5.0.5 (Windows)', '/Author': 'Horizon Interactive', '/Creator': 'FrameMaker 7.0', '/ModDate': "D:20071105105604Z00'00'", '/Title': 'ACS550-01/U1 Drive User’s Manual', '/CreationDate': "D:20071105105604Z00'00'"}
    # print (info)
    # 236
    # print ("number of pages: %i" % pages)

    page = pdf.getPage(2)
    # {'/Type': '/Page', '/Parent': IndirectObject(2317, 0), '/Resources': IndirectObject(2349, 0), '/Contents': [IndirectObject(2352, 0), IndirectObject(2354, 0), IndirectObject(2356, 0), IndirectObject(2358, 0), IndirectObject(2360, 0), IndirectObject(2368, 0), IndirectObject(2370, 0), IndirectObject(2379, 0)], '/CropBox': [0, 0, 612, 792], '/MediaBox': [0, 0, 612, 792], '/Rotate': 0}
    # print(page)
    print(page.extractText())

